import resolve from '@rollup/plugin-node-resolve';
import { babel } from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';

const config = {
  input: 'index.js',
  output: {
    format: 'esm',
    file: 'dist/i18n.esm.js',
  },
  plugins: [
    commonjs(),
    babel({
      babelHelpers: 'bundled'
    }),
    resolve({
      preferBuiltins: true,
      browser: true
    })
  ],
  external: ['vue']
};

if (process.env.NODE_ENV === 'production') {
  config.plugins.push(
    terser()
  );
}

export default config;

